﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>请选择要跳转的节点</title>
    <!--jquery-->
    <script src="../Scripts/jquery-1.11.0.min.js" type="text/javascript"></script>
    <!--公共JS-->
    <script src="../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../Scripts/config.js" type="text/javascript"></script>
    <script src="../Comm/Gener.js" type="text/javascript"></script>

    <!--layui的样式-->
    <link href="../Scripts/layui/layui/css/layui.css" rel="stylesheet" />
    <script src="../Scripts/layui/layui/layui.js" type="text/javascript"></script>
    <script src="../Scripts/layui/LayuiDialog.js" type="text/javascript"></script>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">请选择要跳转的节点</div>
                    <div class="layui-card-body">
                        <div id="content"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script id="initPage" type="text/html">
        <dl class="layuiadmin-card-status">
            {{#  layui.each(d.data, function(index, item){ }}
                {{#  if(item.NodeID!=d.FK_Node){ }}
                <dd>
                    <div class="layui-status-img"><a href="javascript:void(0);" data-nodeid="{{item.NodeID}}" class="jumpway"><i class="layui-icon layui-icon-tabs" style="padding-right:10px"></i>{{item.NodeID}}-{{item.Name}}</a></div>
                </dd>
                {{#  } }}
            {{#  }); }}
        </dl>
    </script>
    <script type="text/javascript">
        var isFrameCross = GetQueryString("isFrameCross");
        if (isFrameCross == null || isFrameCross == undefined || isFrameCross == "" || isFrameCross == "null")
            isFrameCross = 0;
        layui.use("laytpl", function () {
            var laytpl = layui.laytpl;
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
            handler.AddUrlData();
            var data = handler.DoMethodReturnString("JumpWay_Init");
            if (data.indexOf("err@") != -1) {
                layer.alert(data);
                return;
            }
            data = JSON.parse(data);
            var laydata = {};
            laydata.data = data;
            laydata.FK_Node = GetQueryString("FK_Node");
            var getTpl = document.getElementById("initPage").innerHTML
                , view = document.getElementById('content');
            laytpl(getTpl).render(laydata, function (html) {
                view.innerHTML = html;
            });

            $(".jumpway").on('click', function () {
                var nodeID = $(this).data('nodeid');

                var index = layer.load(1);
                var httphandler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
                httphandler.AddUrlData();
                httphandler.AddPara("ToNode", nodeID);
                var data = httphandler.DoMethodReturnString("JumpWay_Send");

                if (data.indexOf('err@') == 0) {  //如果发送失败.

                    layer.alert(data);
                    layer.close(index);
                    
                    return;
                }
                if (isFrameCross == 0) {
                    if (window.parent != null && window.parent.WindowCloseReloadPage != null && typeof window.parent.WindowCloseReloadPage === "function") {
                        window.parent.WindowCloseReloadPage(data);
                    } else {
                        if (typeof WindowCloseReloadPage != 'undefined' && WindowCloseReloadPage instanceof Function)
                            WindowCloseReloadPage(data);
                    }
                }

                if (data.indexOf('TurnUrl@') == 0 || data.indexOf('url@') == 0) {  //发送成功时转到指定的URL
                    layer.close(index);
                    var url = data;
                    url = url.replace('TurnUrl@', '');
                    url = url.replace('url@', '');
                    SetHref(url);
                    return;
                }
                layer.close(index);
                //发送成功处理.
                data = data.replace("'MyFlowInfo", "'../MyFlowInfo");
                data = data.replace("'MyFlow.htm", "'../MyFlow.htm");
                data = data.replace("'MyFlow.htm", "'../MyFlow.htm");

                data = data.replace("'WFRpt", "'../WFRpt");
                data = data.replace("'WFRpt", "'../WFRpt");

                data = data.replace("'./Img", "'../Img");
                data = data.replace("'./Img", "'../Img");
                data = data.replace("'./Img", "'../Img");
                data = data.replace("'./Img", "'../Img");
                data = data.replace("'./Img", "'../Img");

                data = data.replace("'./WorkOpt/", "");
                data = data.replace("'./WorkOpt/", "");
                data = data.replace("'./WorkOpt/", "");
                data = data.replace("'./WorkOpt/", "");

                data = data.replace('<br/>', '');
                data = data.replace('<br/>', '');
                data = data.replace('<br/>', '');
                data = data.replace('@', '<br/>@');
                data = data.replace(/@/g, '<br/>@');


                data = data.replace('@', '<br/>@');
                data = data.replace(/null/g, '');
                data = data.replace("<br><br/><br/>", '');

                data += " <div style='text-align:right;margin-right:10px;margin-bottom:10px'>";
                data += " <button id='CloseBtn' type = 'button'  onclick = 'CloseAll();'><img src='../Img/Btn/Close.png' />关  闭(30秒)</button></div> ";
                $("#content").html(data);

            })
        })

        var WF_WorkOpt_LeftSecond = getConfigByKey("WF_WorkOpt_LeftSecond", 30);
        function clock() {

            if ($("#CloseBtn").length == 0)
                return;
            WF_WorkOpt_LeftSecond >= 0 ? WF_WorkOpt_LeftSecond-- : clearInterval(int);
            $("#CloseBtn").html("<img src='../Img/Btn/Close.png' />关  闭(" + WF_WorkOpt_LeftSecond + "秒)");
            if (WF_WorkOpt_LeftSecond == 0)
                CloseAll();
        }

        //取消移交
        function CloseAll() {

            if (isFrameCross == 0) {
                // 取得父页面URL，用于判断是否是来自测试流程
                var pareUrl = window.top.document.referrer;
                if (pareUrl.indexOf("test") != -1 || pareUrl.indexOf("Test") != -1) {
                    // 测试流程时，发送成功刷新测试容器页面右侧
                    window.parent.parent.refreshRight();
                }

                if (window.parent != null && window.parent.returnWorkWindowClose != null) {
                    window.parent.close();
                    if (window.parent.parent != null && window.parent.parent != undefined
                        && pareUrl.indexOf("test") == -1 && pareUrl.indexOf("Test") == -1)
                        window.parent.parent.close();
                    window.parent.returnWorkWindowClose();
                }
            } else {
                window.parent.parent.close();
                ChildrenPostMessage('', 'returnWorkWindowClose');
            }


            window.close();
        }
    </script>
</body>
</html>